<?php
/**
 * User:于小涛
 * Date:2020/9/15
 * Time:14:07
 */
namespace app\api\controller\system;

use app\api\BaseController;
use app\api\model\system\Channel as ChannelModel;
use think\App;

class Channel extends BaseController{
    private $obj_channel_model=null;
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->obj_channel_model = new ChannelModel();
    }

    public function getChannelList(){
        //如果是推广员则需要筛选渠道，如果是创业经理则不需要
        $arr_role_ids=$this->getRoleIds($this->request->arr_admin_info['id']);
        //如果是推广员和创业导师则只能够查看自己的
        if(in_array(config('project.role_id.tuiguangzhuanyuan.id'),$arr_role_ids)){
            $str_sql="select c.id,c.name from channel_bind_admin as cba left join channel as c on c.id=cba.channel_id where cba.admin_id={$this->request->arr_admin_info['id']} order by c.sort desc";
        }else{
            $str_sql="select id,name from channel order by sort desc";
        }
        $arr_list=$this->obj_channel_model->query($str_sql);
        $arr_re=[
            'list'=>$arr_list
        ];
        return output_data($arr_re);
    }

}